#include "trace/msr.hpp"

/**
 * \file
 * \ingroup trace
 * cas::TraceMsr implementation.
 */

namespace cas
{
    SLOG_COMPONENT_DEFINE("TraceMsr");

    TraceMsr::TraceMsr(std::string path) : TraceDriver(path)
    {
        SLOG_FUNCTION(path);
        data.clear();
    }

    TraceMsr::~TraceMsr()
    {
        SLOG_FUNCTION_NOARGS();
        data.clear();
    }

    size_t TraceMsr::dataSize()
    {
        return data.size();
    }

    bool TraceMsr::parseLine(std::istringstream &sin)
    {
        SLOG_FUNCTION_NOARGS();
        uint64_t timestp;
        uint16_t devno;
        uint64_t lba;
        uint32_t size;
        char rw;
        uint64_t timeres;

        sin >> timestp >> devno >> lba >> size >> rw >> timeres;

        data.emplace_back(timestp, lba, size, devno, rw == 'W');

        return true;
    }

} // namespace cas
